<?php


namespace app\admin\service;


use JiraRestApi\JiraException;
use JiraRestApi\Project\ProjectService;
use think\Log;

class JiraProject
{
    /**
     * 获取所有的jira项目列表
     * @return array
     * @throws \Exception
     */
    public function getAllProjectList()
    {
        try {
            $project_service = new ProjectService();
            $jira_poojects = $project_service->getAllProjects();
            $projects = [];
            foreach ($jira_poojects as $p) {
                $project = [];
                $project['key'] = $p->key;
                $project['id'] = $p->id;
                $project['name'] = $p->name;
                $projects[] = $project;
            }
            return $projects;
        } catch (JiraException $e) {
            Log::error("获取jira项目列表失败..." . $e->getMessage());
        }
    }
}